package com.cool.login.controller;

import com.cool.foundation.controller.BaseController;
import com.cool.login.dao.UserInfoMapper;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Created by sunjt on 2016/4/25
 */
@Controller
public class LoginController extends BaseController {

    @Resource
    MongoTemplate mongoTemplate;
    @Resource
    private Properties remoteConfigs ;
    @Resource
    private UserInfoMapper userInfoMapper;

    @RequestMapping(value = "index")
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
        /*String aaa = mongoTemplate.getCollection("yy_customer").toString();
        System.out.println(aaa);*/
        String staticLink =  remoteConfigs.get("staticLink").toString();
       /* userInfoMapper.selectAll();*/
        ModelAndView mv = new ModelAndView("index","staticLink",staticLink);
        return mv;
    }
    /**
     *
    * @Title: login
    * @Description: TODO(登录)
    * @param @param request
    * @param @param response
    * @return void
    * @author duanws
    * @throws
     */
    @RequestMapping(value = "login")
    public void login(HttpServletRequest request, HttpServletResponse response) {
        /*try {
            response.sendRedirect("/index.jsp#/access/signin");
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }
    @RequestMapping(value = "getSessionUser")
    @ResponseBody
    public Object getSessionUser(HttpServletRequest request, HttpServletResponse response) {
        Map map = new HashMap();
        map.put("user",request.getSession().getAttribute("user"));
        return map;
    }





}
